// pages/Vip/Vip.js
Page({
	data: {
		data: '',
		http: getApp().globalData.map,
		num: 0,
		text: '',
		uid: '',
		num1: '1'
	},

	index(e) {
		this.setData({
			num: e.detail.current
		})
		let a = this.data.data[e.detail.current].Describe.replace('end', '\n')
		let b = a.replace('end', '\n')
		this.setData({
			text: b,
			num1: e.detail.current + 1
		})
		console.log(e.detail)
	},
	nav(e) {
		var item = e.detail.value //选中的数组
		var id = []; //选中的ID
		var name = []; //选中的NAME

		//循环选中的数组，取出对应的数据进行数组拼接
		for (var i = 0; i < item.length; i++) {
			var row = item[i].split(",") //将数组进行分割
			id = id.concat(row[0]) //数组下表的第一个为id
			name = name.concat(row[1]) //数组下表的第二个为name
		}
		console.log(id)
		console.log(name)
		this.setData({
			name: name,
			list: id,
		})
	},
	txt(){
		let a = this.data.list
		let n=this.data.name
		n=n.join()
		a = a.join()
		wx.navigateTo({
			url: '../../share/li/li?type=' + a + '&id=' + this.data.data[this.data.num].CardID + '&map=' + this.data.data[this.data.num].shopName + '&name=' + n
		})
	},
	/**
	 * 生命周期函数--监听页面显示
	 */
	onShow: function() {
		wx.getStorage({
			key: 'uid',
			success: (e) => {
				wx.request({
					url: getApp().globalData.http + 'action=mycardList&uid=' + e.data.uid,
					success: (e) => {
						console.log(e)
						this.setData({
							data: e.data.data,
						})
					}
				})
			}
		})
	},
	sure(e){
		let list=[]
		let num=[]
		this.data.data[e.currentTarget.dataset.id].items.forEach(function(item,index){
			list.push(item.ID)
		})
		this.data.data[e.currentTarget.dataset.id].items.forEach(function(item,index){
			num.push(item.SNums)
		})
		let that=this
		num=num.join()
		list=list.join()
		setTimeout(function(){
			wx.navigateTo({ 
				url:'list/list?id='+that.data.data[e.currentTarget.dataset.id].CardID
				+'&ord='+that.data.data[e.currentTarget.dataset.id].items[0].OrderCode+'&oid='+list+'&num='+num
			})
		},200) 
	}
})
